import { createAction } from 'redux-actions'
import { UPDATE_HOME_PAGE_TYPE_C } from './type'
import { HomeBannerRequest, HomeJobRequest } from 'src/utils/RequestAPI'

/* async */
export const DO_REQUEST_HOME_BANNER_ACTION_C = createAction(UPDATE_HOME_PAGE_TYPE_C, (...args) => {
  return new Promise((resolve, reject) => {
    HomeBannerRequest(...args).then(res => {
      if (res.code === 200) {
        const banners = res['[]'].map(e => e.carousel_map)
        resolve({
          banners
        })
      }
    })
  })
})
export const DO_REQUEST_HOME_JOB_ACTION_C = createAction(UPDATE_HOME_PAGE_TYPE_C, (...args) => {
  return new Promise((resolve, reject) => {
    HomeJobRequest(...args).then(res => {
      if (res.status) {
        const jobList = res['entry']
        resolve({
          jobList
        })
      }
    })
  })
})
